<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试性能</title>
</head>

<body>

</body>
<script>
  const file = [...Array(100)];
  console.log('file', file);
  const suffix = 'png';
  const pat = () => {
    let cur = 0;
    const partsize = 1;
    const partList = [];
    [...Array(100)].forEach(() => {
      let data = {
        chunk: file.slice(cur, cur + 1),
        filename: encodeURIComponent(`${Math.random()}.${suffix}`),
      };
      cur += partsize;
      partList.push(data);
    });
    console.log('partList_pat', partList, partList.length);
  }
  console.time('pat')
  pat()
  console.timeEnd('pat')
  const forXun = () => {
    let cur = 0;
    const partsize = 1;
    const partList = [];
    for (let i = 0; i < 100; i++) {
      let item = {
        chunk: file.slice(cur, cur + 1),
        filename: encodeURIComponent(`${Math.random()}.${suffix}`),
      };
      cur += partsize;
      partList.push(item)
    }
    console.log('partList_forXun', partList, partList.length);
  }
  console.time('forXun')
  forXun()
  console.timeEnd('forXun')

</script>
<script>
  let spliceArr = [1, 2, 3, 4];
  console.log('原始数组spliceArr_splice前', spliceArr);/*[1,4]*/
  const newArr = spliceArr.splice(1, 2);
  console.log('newArr', newArr); // [2, 3]
  console.log('原始数组spliceArr_splice后', spliceArr); //[1, 4]
  // splice方法截取会改变原始数组,所以vue2当中封装了这个响应式方法。两个参数
  // 参数1是从哪个位置开始截取,参数二是截取到哪一个索引结束,包前也包后

</script>

</html>
